package com.myapplication.zhou.alldemo;

import android.support.v4.widget.NestedScrollView;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.myapplication.callback.GoodsInfoCallback;
import com.myapplication.interfaces.GoodsInfoConnect;
import com.myapplication.model.GoodsInfo;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

public class GoodsInfoForVirtualActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener,GoodsInfoCallback
  ,View.OnClickListener{
    @ViewInject(R.id.nestedScrollView)
    private NestedScrollView nestedScrollView;
    @ViewInject(R.id.swipeRefresh)
    private SwipeRefreshLayout refreshLayout;
    @ViewInject(R.id.textView_good_name)
    private TextView textViewGoodName;
    @ViewInject(R.id.textView_good_price)
    private TextView textViewGoodPrice;
    @ViewInject(R.id.tihuofangshi)
    private TextView textView_tihuofangshi;
    @ViewInject(R.id.youxiaoqi)
    private TextView textView_youxiaoqi;
    @ViewInject(R.id.number)
    private TextView textView_number;
    private GoodsInfo goodsInfo;
    private GoodsInfoConnect goodsInfoConnect;
    private String goods_id;
    @ViewInject(R.id.textView_shop_cart)
    private TextView textView_shop_cart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goods_info_for_virtual);
        x.view().inject(this);
        refreshLayout.setOnRefreshListener(this);
        refreshLayout.setColorSchemeResources(android.R.color.holo_orange_light, android.R.color.holo_blue_bright,
                android.R.color.holo_green_light, android.R.color.holo_red_light);
        goodsInfoConnect = new GoodsInfoConnect();
        Bundle bundle = getIntent().getExtras();
        goods_id = bundle.getString("goods_id");

    }

    private void getLogin(){

    }

    @Override
    protected void onResume() {
        super.onResume();
        nestedScrollView.setVisibility(View.GONE);
        swipeRefreshPost();
    }

    @Override
    public void onRefresh() {
        refreshLayout.setRefreshing(true);
        goodsInfoConnect.getGoodsInfo(goods_id,this);
    }

    @Override
    public void onGoodsInfoSuccess(String json) {
        refreshLayout.setRefreshing(false);

    }

    @Override
    public void onGoodsInfoFail(String fail) {
        refreshLayout.setRefreshing(false);
    }

    /**初始化更新*/
    public void swipeRefreshPost() {
        refreshLayout.post(new Runnable() {
            @Override
            public void run() {
                onRefresh();
            }
        });
    }

    /**点击事件*/
    @Override
    public void onClick(View v) {

    }
}
